﻿/**
  ******************************************************************************
  * File:    1wire.h
  * Author:  Michal Mazur
  * Date:    11-October-2013 -Last modification
  * Brief:   This file contains declaration for 1wire interface
  ******************************************************************************
  * Attention
  *
  *
  *             Copyright (c) 2013 by HC . All rights reserved
  ******************************************************************************
  *****************************************************************************/

#ifndef ONE_WIRE_H_
#define ONE_WIRE_H_

// Includes ********************************************************************
#include <avr/io.h>
#include <util/delay.h>

// Defines  ********************************************************************

#define ONE_WIRE_PORT		PORTD
#define ONE_WIRE_DDR		DDRD
#define ONE_WIRE_NUM_PORT	PORTD5
#define ONE_WIRE_PIN		PIND


#define ONE_WIRE_PIN_SET	ONE_WIRE_PORT |= (1<<ONE_WIRE_NUM_PORT)
#define ONE_WIRE_PIN_RESET	ONE_WIRE_PORT &= ~(1<<ONE_WIRE_NUM_PORT)

#define ONE_WIRE_PIN_OUT	ONE_WIRE_DDR |= (1<<ONE_WIRE_NUM_PORT)
#define ONE_WIRE_PIN_IN		ONE_WIRE_DDR &= ~(1<<ONE_WIRE_NUM_PORT)

#define ONE_WIRE_PIN_READ	(ONE_WIRE_PIN & (1<<ONE_WIRE_NUM_PORT))
// Functions *******************************************************************
void OneWire_Init(void);
uint8_t OneWire_Reset(void);
void OneWire_Send(uint8_t bit);
uint8_t OneWire_Read(void);
void OneWire_SendByte(uint8_t data);
uint8_t OneWire_ReadByte(void);


#endif /* ONE_WIRE_H_ */

/* END OF FILE *****************************************************************
 *
 */
